package com.quick.service;

import com.quick.domain.Order;
import com.quick.util.SpringContextUtil;
import org.springframework.stereotype.Service;

/**
 * @ClassName ActionHandleServiceImpl
 * @Description TODO
 * @Author jojo.wang
 * @Date 2019-05-24 21:44
 * @Version 1.0
 **/
@Service
public class ActionHandleServiceImpl implements ActionHandleService{
    @Override
    public Object handler(String serviceName, Order order, String param) throws Exception{
        try {
            Object handleService = SpringContextUtil.getBean(serviceName);
            if(handleService instanceof ActionInterface){
                return ((ActionInterface) handleService).handler(order,param);
            }else {
                throw new Exception("ActionHandleServiceImpl handle serviceError[serviceName="+serviceName+"]");
            }
        }catch (Exception e){
            throw new Exception("ActionHandleServiceImpl handle ERROR [serviceName="+serviceName+"]");
        }
    }
}
